﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Microsoft.SharePoint;

namespace DevSky.SharePoint.Core.Controls
{
  public class ProgressLoadingTemplate : ITemplate
  {
    public string ImagePath { get; set; }
    public string DisplayText { get; set; }

    public ProgressLoadingTemplate(string imagePath, string displayText)
    {
      ImagePath = (imagePath == null || imagePath.Length == 0) ? "/_layouts/images/DevSkySolutions/loading.gif" : imagePath;
      DisplayText = displayText;
    }

    public void InstantiateIn(Control container)
    {
      Image img = new Image();
      img.CssClass = "northwind-progressTemplate-Image-Task";
      img.ImageUrl = ImagePath;

      Label lbl = new Label() { ID = "lblProgressIndicatorText", CssClass = "devsky-wp-progressTemplate-Label-Task" };
      lbl.Text = DisplayText;
      
      Panel outerPanel = new Panel() { ID = "outerPanel" };
      outerPanel.CssClass = "devsky-wp-progressTemplateContainer-Task";

      Panel innerPanel = new Panel() { ID = "innerPanel" };
      innerPanel.CssClass = "devsky-wp-progressTemplateInner-Task";
      innerPanel.Controls.Add(img);
      innerPanel.Controls.Add(lbl);
      outerPanel.Controls.Add(innerPanel);

      container.Controls.Add(outerPanel);
    }


  }
}
